package api;

import com.fasterxml.jackson.databind.ObjectMapper;
import model.Album;
import model.DBUtil;
import model.Story;
import service.AlbumService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

@WebServlet("/api/album-detail.json")
public class AlbumDetailApi extends AbsApiServlet {
   private final AlbumService albumService = new AlbumService();
    @Override
    protected Object doGetInner (HttpServletRequest req, HttpServletResponse resp) throws SQLException, ServletException, IOException, APIException {
        req.setCharacterEncoding("utf-8");
        int aid = Integer.parseInt(req.getParameter("aid"));
   try(Connection c = DBUtil.getConnection()){
    return albumService.get(c,aid);
}
    }
}